# !/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2025/9/22 14:35
# @Author  : Dell
# @File    : simple_chain.py
# @Software: PyCharm
# @Desc    :简单的顺序链
from langchain.chains import LLMChain
from langchain_core.prompts import PromptTemplate
from langchain.chains import SimpleSequentialChain
from langchain_openai import ChatOpenAI


llm = ChatOpenAI(model_name='qwen-plus', base_url="https://dashscope.aliyuncs.com/compatible-mode/v1", temperature=0.5,
                 api_key="sk-7b4f290b1a3e42a1a9a1957fa44eff37")
# 创建生成经典菜肴的链
template1 = """ 您的工作是想出一道用户建议的该地区的经典菜肴。用户地区{user_location} 你的回答："""
meal_template = PromptTemplate(input_variables=["user_location"],template=template1)

# 创建美食链
location_chain_meal = meal_template| llm
review = location_chain_meal.invoke({"user_location":"上海"})
print(review)


# 创建生成广告语的链
template2="为{food}创作一段简洁有力的广告语，不超过20字。只需返回广告语"
iaa_template= PromptTemplate(input_variables=["food"],template=template2)
location_chain_iaa = iaa_template | llm
review2=location_chain_iaa.invoke({"food":"红烧肉"})
print(review2)